package com.itheima.exerciseTest.method30_39.method30;

import java.util.concurrent.atomic.AtomicInteger;

public class Schoolmate implements Runnable {
    private Warehouse w;
    public Schoolmate(Warehouse w){
        this.w = w;
    }
    private AtomicInteger ai = new AtomicInteger();


    @Override
    public void run() {
        while(true){
            if(w.getNumberScope() <= 0){
                break;
            }
            ai.getAndSet(w.getNumberScope());
            w.setNumberScope(ai.decrementAndGet());
            if(ai.get() % 2 != 0){
                System.out.println(Thread.currentThread().getName() + ai.get());
            }

        }
    }
}